package com.beiye.drivertransport.thematic.learning;


import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;
import android.net.Uri;
import android.support.v4.app.Fragment;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.AdapterView;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.RadioButton;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.alibaba.fastjson.JSON;
import com.android.frame.adapter.CommonAdapter;
import com.android.frame.adapter.ViewHolder;
import com.beiye.drivertransport.R;
import com.beiye.drivertransport.SubActivity.LearnthemticlearningDetailsActivity;
import com.beiye.drivertransport.bean.ExeciseCourseBean;
import com.beiye.drivertransport.bean.ExerciseTypeBean;
import com.beiye.drivertransport.config.AppInterfaceConfig;
import com.beiye.drivertransport.fragment.TwoBaseFgt;
import com.beiye.drivertransport.http.Login;
import com.beiye.drivertransport.view.LiumRadioGroup;
import com.example.mylibrary.paper.utils.QuestionAnswerUtils;
import com.squareup.picasso.Picasso;

import org.greenrobot.eventbus.EventBus;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;


import butterknife.OnClick;
import okhttp3.Call;
import okhttp3.Response;

/**
 * A simple {@link Fragment} subclass.
 */
//习题
public class ExercisesthematiclearingFragment extends TwoBaseFgt {
    private int firstIndex = 1;
    private int pageSize = 10000;

    View empty_view;

    ListView lv_exercise;

    EditText ed_exercise;

    ImageView img_exercise;//搜索

    ImageView img_delet;//清除内容
    //  @Bind(R.id.tv_exercise5)
//  TextView tv_exercise5;//多少题

    TextView tv_exercise2;

    RelativeLayout re_exercise;
    private ExerciseCourseAdatper exerciseCourseAdatper;
    private ArrayList<ExeciseCourseBean.RowsBean> rowslist = new ArrayList<>();
    ArrayList<ExerciseTypeBean> typeList = new ArrayList<>();
    private PopWindowTypeApt popWindowTypeApt;
    private PopupWindow mPopWindowType;

    @Override
    public int getLayoutId() {
        return R.layout.fragment_exercisesthematiclearing;
    }


    @Override
    public void onClick(View view) {

    }

    @Override
    public void initData() {
        int stId = getArguments().getInt("stId");
        if (stId == 0) {
            lv_exercise.setEmptyView(empty_view);
            return;
        }
        SharedPreferences sp = getActivity().getSharedPreferences("ExercisesthematiclearingFragment",
                Context.MODE_PRIVATE);
        SharedPreferences.Editor edit = sp.edit();
        edit.putInt("stId", stId);
        edit.commit();
        initType();
        ed_exercise.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
                //如果长度为0
                if (charSequence.length() == 0) {
                    img_delet.setVisibility(View.GONE);
                } else {
                    img_delet.setVisibility(View.VISIBLE);

                }
            }

            @Override
            public void afterTextChanged(Editable editable) {

            }
        });

        ed_exercise.setOnTouchListener(new View.OnTouchListener() {

            @SuppressLint("ClickableViewAccessibility")
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (MotionEvent.ACTION_DOWN == event.getAction()) {
                    ed_exercise.setCursorVisible(true);// 再次点击显示光标
                }
                return false;
            }
        });
    }

    private void showTypePopupWindow() {
        //设置contentView
        View contentView = LayoutInflater.from(getActivity()).inflate(R.layout.popwindowexercisetype_layout, null);
        mPopWindowType = new PopupWindow(contentView,
                WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, true);
        //设置各个控件的点击响应
        ListView lv_role = (ListView) contentView.findViewById(R.id.lv_role);

        lv_role.setAdapter(popWindowTypeApt);
        mPopWindowType.showAtLocation(tv_exercise2, Gravity.CENTER, 0, 0);
        LinearLayout le_exercise = contentView.findViewById(R.id.le_exercise);
        RelativeLayout re_exercise = contentView.findViewById(R.id.re_exercise);
        le_exercise.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mPopWindowType.dismiss();
            }
        });
        re_exercise.setOnClickListener(null);
        lv_role.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
                if (popWindowTypeApt != null) {
                    mPopWindowType.dismiss();
                    String typename = popWindowTypeApt.getItem(position).getTypename();
                    tv_exercise2.setText(typename);
                    SharedPreferences sp = getActivity().getSharedPreferences("ExercisesthematiclearingFragment",
                            Context.MODE_PRIVATE);
                    SharedPreferences.Editor edit = sp.edit();
                    edit.putString("typename", typename);
                    edit.commit();
                    initTypeData(typename);
                }
            }
        });

    }


    private void initType() {

        typeList.clear();
        typeList.add(new ExerciseTypeBean("全部"));
        typeList.add(new ExerciseTypeBean("单选题"));
        typeList.add(new ExerciseTypeBean("复选题"));
        typeList.add(new ExerciseTypeBean("判断题"));
        String typename = typeList.get(0).getTypename();
        tv_exercise2.setText(typename);
        SharedPreferences sp = getActivity().getSharedPreferences("ExercisesthematiclearingFragment",
                Context.MODE_PRIVATE);
        SharedPreferences.Editor edit = sp.edit();
        edit.putString("typename", typename);
        edit.commit();
        initTypeData(typename);
        popWindowTypeApt = new PopWindowTypeApt(getContext(), typeList, R.layout.popwindow_item_layout);
    }

    private void initTypeData(String typename) {

        SharedPreferences sp = getActivity().getSharedPreferences("ExercisesthematiclearingFragment",
                Context.MODE_PRIVATE);
        int stId = sp.getInt("stId", 0);
        String exercisename = ed_exercise.getText().toString().trim();
        if (exercisename.equals("")) {
            if (typename.equals("全部")) {
                showLoadingDialog("");
                new Login().getExerciseData(stId, "", "", firstIndex, pageSize, this, 1);
            } else if (typename.equals("单选题")) {
                showLoadingDialog("");
                new Login().getExerciseData(stId, "", 1 + "", firstIndex, pageSize, this, 1);
            } else if (typename.equals("复选题")) {
                showLoadingDialog("");
                new Login().getExerciseData(stId, "", 2 + "", firstIndex, pageSize, this, 1);
            } else if (typename.equals("判断题")) {
                showLoadingDialog("");
                new Login().getExerciseData(stId, "", 3 + "", firstIndex, pageSize, this, 1);
            }
        } else {

            if (typename.equals("全部")) {
                showLoadingDialog("");
                new Login().getExerciseData(stId, exercisename, "", firstIndex, pageSize, this, 1);
            } else if (typename.equals("单选题")) {
                showLoadingDialog("");
                new Login().getExerciseData(stId, exercisename, 1 + "", firstIndex, pageSize, this, 1);
            } else if (typename.equals("复选题")) {
                showLoadingDialog("");
                new Login().getExerciseData(stId, exercisename, 2 + "", firstIndex, pageSize, this, 1);
            } else if (typename.equals("判断题")) {
                showLoadingDialog("");
                new Login().getExerciseData(stId, exercisename, 3 + "", firstIndex, pageSize, this, 1);
            }

        }


    }

    @Override
    public void requestData() {

//    SharedPreferences sp = getActivity().getSharedPreferences("ExercisesthematiclearingFragment",
//            Context.MODE_PRIVATE);
//     int stId = sp.getInt("stId", 0);
//      new Login().getExerciseData(stId,  "", "", firstIndex, pageSize, this, 2);
    }

    @Override
    public void onSuccess(String result, Call call, Response response, int what) {
        if (what == 1) {
            dismissLoadingDialog();
            ExeciseCourseBean execiseCourseBean = JSON.parseObject(result, ExeciseCourseBean.class);
            List<ExeciseCourseBean.RowsBean> rows = execiseCourseBean.getRows();
            rowslist.clear();
            if (rows.size() == 0) {
                lv_exercise.setEmptyView(empty_view);
                return;
            }
            for (int i = 0; i < rows.size(); i++) {
                rowslist.add(rows.get(i));
            }
            exerciseCourseAdatper = new ExerciseCourseAdatper(getContext(), rowslist, R.layout.exercise_item_layout);
            lv_exercise.setAdapter(exerciseCourseAdatper);


        }
//      else if(what==2)
//      {
//        ExeciseCourseBean execiseCourseBean = JSON.parseObject(result, ExeciseCourseBean.class);
//        if(execiseCourseBean != null)
//        {
//          List<ExeciseCourseBean.RowsBean> rows = execiseCourseBean.getRows();
//          if(rows.size()==0)
//          {
//            tv_exercise5.setText("共0题");
//          }else{
//            tv_exercise5.setText("共"+rows.size()+"题");
//          }
//        }
//      }

        super.onSuccess(result, call, response, what);
    }

    @Override
    public void onUserVisible() {

    }

    @Override
    public boolean onTouch(View v, MotionEvent event) {
        return false;
    }


//  private void initUi() {
//    LinearLayoutManager ms = new LinearLayoutManager(getContext());
//    ms.setOrientation(LinearLayoutManager.VERTICAL);
//    lv_exercise.setLayoutManager(ms);
//    exerciseCourseAdatper = new ExerciseCourseAdatper(getContext());
//    lRecyclerViewAdapter1 = new LRecyclerViewAdapter(exerciseCourseAdatper);
//    lv_exercise.setAdapter(lRecyclerViewAdapter1);
//    lv_exercise.setFooterViewColor(R.color.colorAccent, R.color.dark, android.R.color.white);
//    lv_exercise.setFooterViewHint("拼命加载中", "已经全部为你呈现了", "网络不给力啊，点击再试一次吧");
//    lv_exercise.setOnRefreshListener(new OnRefreshListener() {
//
//      @Override
//      public void onRefresh() {
//        firstIndex = 1;
//        requestData();
//      }
//    });
//
//    lv_exercise.setOnLoadMoreListener(new OnLoadMoreListener() {
//
//      @Override
//      public void onLoadMore() {
//        firstIndex += pageSize;
//        requestData();
//      }
//    });
//    empty_view.setOnClickListener(new View.OnClickListener() {
//      @Override
//      public void onClick(View v) {
//        lv_exercise.refresh();
//      }
//    });
//
//    lv_exercise.refresh();
//
//  }


    public class ExerciseCourseAdatper extends CommonAdapter<ExeciseCourseBean.RowsBean> {
        private Context context;
        private List<ExeciseCourseBean.RowsBean> mList;

        public ExerciseCourseAdatper(Context context, List<ExeciseCourseBean.RowsBean> mList, int itemLayoutId) {
            super(context, mList, itemLayoutId);
            this.context = context;
            this.mList = mList;

        }


        @Override
        public void convert(ViewHolder holder, ExeciseCourseBean.RowsBean item, int positon) {
            ExeciseCourseBean.RowsBean rowsBean = mList.get(positon);
            String optionA = rowsBean.getOptionA();
            String optionB = rowsBean.getOptionB();
            String optionC = rowsBean.getOptionC();
            String optionD = rowsBean.getOptionD();
            String optionE = rowsBean.getOptionE();
            String optionF = rowsBean.getOptionF();
            String questionDesc = rowsBean.getQuestionDesc();
            int type = rowsBean.getqType();
            String url = rowsBean.getUrl();
            String rightOption = rowsBean.getRightOption();


            ImageView img_execise = holder.getView(R.id.img_execise);//图片
            TextView tv_execise = holder.getView(R.id.tv_execise);//描述
            TextView tv_num = holder.getView(R.id.tv_num);//习题号
            TextView tv_numname = holder.getView(R.id.tv_numname);//选题类型
//      LinearLayout lg = holder.getView(R.id.lg);
//      LinearLayout line_A = holder.getView(R.id.line_A);
//      TextView radioButton_execise = holder.getView(R.id.radioButton_execise);
//      LinearLayout line_B = holder.getView(R.id.line_B);
//      TextView radioButton_execise1 = holder.getView(R.id.radioButton_execise1);
//      LinearLayout line_C = holder.getView(R.id.line_C);
//      TextView radioButton_execise2 = holder.getView(R.id.radioButton_execise2);
//      LinearLayout line_D = holder.getView(R.id.line_D);
//      TextView radioButton_execise3 = holder.getView(R.id.radioButton_execise3);
//      LinearLayout line_E= holder.getView(R.id.line_E);
//      TextView radioButton_execise4 = holder.getView(R.id.radioButton_execise4);
//      LinearLayout line_F= holder.getView(R.id.line_F);
//      TextView radioButton_execise5 = holder.getView(R.id.radioButton_execise5);
            TextView tv_right = holder.getView(R.id.tv_execise8);//正确标记
            LiumRadioGroup rg = holder.getView(R.id.rg);
            RadioButton rd_exercise = holder.getView(R.id.rd_exercise);
            RadioButton rd_exercise1 = holder.getView(R.id.rd_exercise1);
            RadioButton rd_exercise2 = holder.getView(R.id.rd_exercise2);
            RadioButton rd_exercise3 = holder.getView(R.id.rd_exercise3);
            RadioButton rd_exercise4 = holder.getView(R.id.rd_exercise4);
            RadioButton rd_exercise5 = holder.getView(R.id.rd_exercise5);
            RelativeLayout re_checkbox = holder.getView(R.id.re_checkbox);
//      CheckBox cb_exercise = holder.getView(R.id.cb_exercise);
//      CheckBox cb_exercise1 = holder.getView(R.id.cb_exercise1);
//      CheckBox cb_exercise2 = holder.getView(R.id.cb_exercise2);
//      CheckBox cb_exercise3 = holder.getView(R.id.cb_exercise3);
//      CheckBox cb_exercise4 = holder.getView(R.id.cb_exercise4);
//      CheckBox cb_exercise5= holder.getView(R.id.cb_exercise5);


//      SharedPreferences sp = getActivity().getSharedPreferences("ExercisesthematiclearingFragment",
//              Context.MODE_PRIVATE);
//      int stId = sp.getInt("stId", 0);
            if (url == null) {
                img_execise.setVisibility(View.GONE);

            } else {
                img_execise.setVisibility(View.VISIBLE);
                if (url.contains("aliyuncs.com")) {
                    Picasso.with(context).load(Uri.parse(url)).placeholder(R.mipmap.no_data2).into(img_execise);
                } else {

                    Picasso.with(context).load(Uri.parse(AppInterfaceConfig.getRequestUrl(url))).placeholder(R.mipmap.no_data2).into(img_execise);
                }
            }
            if (questionDesc == null) {
                tv_execise.setText("");
            } else {
                String questionDesc1 = questionDesc.replaceAll("<string>", "").replaceAll("</string>", "").replaceAll("<entry>", "").replaceAll("</entry>", "");
                tv_execise.setText(questionDesc1);
            }


            tv_right.setText(rightOption);
//    if(stId==100001){
//        tv_right.setVisibility(View.VISIBLE);
//        tv_right.setText(rightOption);
//        lg.setVisibility(View.VISIBLE);
//        rg.setVisibility(View.GONE);
//      }else{
//        tv_right.setVisibility(View.VISIBLE);
//        tv_right.setText(rightOption);
//        lg.setVisibility(View.GONE);
//        rg.setVisibility(View.VISIBLE);
//      }


            tv_num.setText(positon + 1 + "");

            if (type == 1) {
                tv_numname.setText("单选题");
                rg.setVisibility(View.VISIBLE);
                re_checkbox.setVisibility(View.GONE);

                if (optionA == null || optionA.equals("")) {
                    rd_exercise.setVisibility(View.GONE);
                } else {
                    rd_exercise.setVisibility(View.VISIBLE);
                    rd_exercise.setText("A." + optionA);
                }
                if (optionB == null || optionB.equals("")) {
                    rd_exercise1.setVisibility(View.GONE);

                } else {
                    rd_exercise1.setVisibility(View.VISIBLE);
                    rd_exercise1.setText("B." + optionB);

                }
                if (optionC == null || optionC.equals("")) {
                    rd_exercise2.setVisibility(View.GONE);
                } else {
                    rd_exercise2.setVisibility(View.VISIBLE);
                    rd_exercise2.setText("C." + optionC);

                }
                if (optionD == null || optionD.equals("")) {
                    rd_exercise3.setVisibility(View.GONE);

                } else {
                    rd_exercise3.setVisibility(View.VISIBLE);
                    rd_exercise3.setText("D." + optionD);
                }
                if (optionE == null || optionE.equals("")) {
                    rd_exercise4.setVisibility(View.GONE);
                } else {
                    rd_exercise4.setVisibility(View.VISIBLE);
                    rd_exercise4.setText("E." + optionE);

                }
                if (optionF == null || optionF.equals("")) {
                    rd_exercise5.setVisibility(View.GONE);
                } else {
                    rd_exercise5.setVisibility(View.VISIBLE);
                    rd_exercise5.setText("F." + optionF);
                }

            } else if (type == 2) {
                tv_numname.setText("多选题");
//        rg.setVisibility(View.GONE);
//        re_checkbox.setVisibility(View.VISIBLE);
//
//        if (optionA == null) {
//          cb_exercise.setVisibility(View.GONE);
//        } else {
//          cb_exercise.setVisibility(View.VISIBLE);
//          cb_exercise.setText("A." + optionA);
//        }
//        if (optionB == null) {
//          cb_exercise1.setVisibility(View.GONE);
//
//        } else {
//          cb_exercise1.setVisibility(View.VISIBLE);
//          cb_exercise1.setText("B."+optionB);
//
//        }
//        if (optionC == null) {
//          cb_exercise2.setVisibility(View.GONE);
//        } else {
//          cb_exercise2.setVisibility(View.VISIBLE);
//          cb_exercise2.setText("C."+optionC);
//
//        }
//        if (optionD == null) {
//          cb_exercise3.setVisibility(View.GONE);
//
//        } else {
//          cb_exercise3.setVisibility(View.VISIBLE);
//          cb_exercise3.setText("D."+optionD);
//        }
//        if (optionE == null) {
//          cb_exercise4.setVisibility(View.GONE);
//        } else {
//          cb_exercise4.setVisibility(View.VISIBLE);
//          cb_exercise4.setText("E."+optionE);
//
//        }
//        if (optionF == null) {
//          cb_exercise5.setVisibility(View.GONE);
//        } else {
//          cb_exercise5.setVisibility(View.VISIBLE);
//          cb_exercise5.setText("F."+optionF);
//        }
                rg.setVisibility(View.VISIBLE);
                re_checkbox.setVisibility(View.GONE);

                if (optionA == null || optionA.equals("")) {
                    rd_exercise.setVisibility(View.GONE);
                } else {
                    rd_exercise.setVisibility(View.VISIBLE);
                    rd_exercise.setText("A." + optionA);
                }
                if (optionB == null || optionB.equals("")) {
                    rd_exercise1.setVisibility(View.GONE);

                } else {
                    rd_exercise1.setVisibility(View.VISIBLE);
                    rd_exercise1.setText("B." + optionB);

                }
                if (optionC == null || optionC.equals("")) {
                    rd_exercise2.setVisibility(View.GONE);
                } else {
                    rd_exercise2.setVisibility(View.VISIBLE);
                    rd_exercise2.setText("C." + optionC);

                }
                if (optionD == null || optionD.equals("")) {
                    rd_exercise3.setVisibility(View.GONE);

                } else {
                    rd_exercise3.setVisibility(View.VISIBLE);
                    rd_exercise3.setText("D." + optionD);
                }
                if (optionE == null || optionE.equals("")) {
                    rd_exercise4.setVisibility(View.GONE);
                } else {
                    rd_exercise4.setVisibility(View.VISIBLE);
                    rd_exercise4.setText("E." + optionE);

                }
                if (optionF == null || optionF.equals("")) {
                    rd_exercise5.setVisibility(View.GONE);
                } else {
                    rd_exercise5.setVisibility(View.VISIBLE);
                    rd_exercise5.setText("F." + optionF);
                }

            } else if (type == 3) {
                tv_numname.setText("判断题");
                rg.setVisibility(View.VISIBLE);
                re_checkbox.setVisibility(View.GONE);

                if (optionA == null || optionA.equals("")) {
                    rd_exercise.setVisibility(View.GONE);
                } else {
                    rd_exercise.setVisibility(View.VISIBLE);
                    rd_exercise.setText("A." + optionA);
                }
                if (optionB == null || optionB.equals("")) {
                    rd_exercise1.setVisibility(View.GONE);

                } else {
                    rd_exercise1.setVisibility(View.VISIBLE);
                    rd_exercise1.setText("B." + optionB);

                }
                if (optionC == null || optionC.equals("")) {
                    rd_exercise2.setVisibility(View.GONE);
                } else {
                    rd_exercise2.setVisibility(View.VISIBLE);
                    rd_exercise2.setText("C." + optionC);

                }
                if (optionD == null || optionD.equals("")) {
                    rd_exercise3.setVisibility(View.GONE);

                } else {
                    rd_exercise3.setVisibility(View.VISIBLE);
                    rd_exercise3.setText("D." + optionD);
                }
                if (optionE == null || optionE.equals("")) {
                    rd_exercise4.setVisibility(View.GONE);
                } else {
                    rd_exercise4.setVisibility(View.VISIBLE);
                    rd_exercise4.setText("E." + optionE);

                }
                if (optionF == null || optionF.equals("")) {
                    rd_exercise5.setVisibility(View.GONE);
                } else {
                    rd_exercise5.setVisibility(View.VISIBLE);
                    rd_exercise5.setText("F." + optionF);
                }

            }


            rg.setOnCheckedChangeListener(null);
            switch (item.getChecked()) {
                case 1:
                    rg.check(R.id.rd_exercise);
                    tv_right.setVisibility(View.VISIBLE);
                    tv_right.setText(rightOption);
                    break;
                case 2:

                    rg.check(R.id.rd_exercise1);
                    tv_right.setVisibility(View.VISIBLE);
                    tv_right.setText(rightOption);
                    break;
                case 3:

                    rg.check(R.id.rd_exercise2);
                    tv_right.setVisibility(View.VISIBLE);
                    tv_right.setText(rightOption);
                    break;
                case 4:

                    rg.check(R.id.rd_exercise3);
                    tv_right.setVisibility(View.VISIBLE);
                    tv_right.setText(rightOption);
                    break;
                case 5:
                    rg.check(R.id.rd_exercise4);
                    tv_right.setVisibility(View.VISIBLE);
                    tv_right.setText(rightOption);
                    break;
                case 6:
                    rg.check(R.id.rd_exercise5);
                    tv_right.setVisibility(View.VISIBLE);
                    tv_right.setText(rightOption);
                    break;
                default:
                    rg.clearCheck();
                    break;
            }
            rg.setId(positon);
            rg.setOnCheckedChangeListener(new LiumRadioGroup.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(LiumRadioGroup group, int checkedId) {
                    item.setSelect(true);

                    if (checkedId == R.id.rd_exercise) {
                        rowsBean.setChecked(1);
                        tv_right.setVisibility(View.VISIBLE);
                        tv_right.setText(rightOption);
                    } else if (checkedId == R.id.rd_exercise1) {
                        rowsBean.setChecked(2);
                        tv_right.setVisibility(View.VISIBLE);
                        tv_right.setText(rightOption);
                    } else if (checkedId == R.id.rd_exercise2) {
                        rowsBean.setChecked(3);
                        tv_right.setVisibility(View.VISIBLE);
                        tv_right.setText(rightOption);
                    } else if (checkedId == R.id.rd_exercise3) {
                        rowsBean.setChecked(4);
                        tv_right.setVisibility(View.VISIBLE);
                        tv_right.setText(rightOption);
                    } else if (checkedId == R.id.rd_exercise4) {
                        rowsBean.setChecked(5);
                        tv_right.setVisibility(View.VISIBLE);
                        tv_right.setText(rightOption);
                    } else if (checkedId == R.id.rd_exercise5) {
                        rowsBean.setChecked(6);
                        tv_right.setVisibility(View.VISIBLE);
                        tv_right.setText(rightOption);
                    }
                }
            });

//      cb_exercise.setOnClickListener(new View.OnClickListener() {
//        @Override
//        public void onClick(View v) {
//         if(cb_exercise.isChecked())
//         {
//           mList.get(positon).setSelect(true);//保存
//         }else{
//           mList.get(positon).setSelect(false);//保存
//         }
//        }
//      });
//     cb_exercise.setChecked( mList.get(positon).isSelect());
//
//      cb_exercise1.setOnClickListener(new View.OnClickListener() {
//        @Override
//        public void onClick(View v) {
//          if(cb_exercise1.isChecked())
//          {
//            mList.get(positon).setSelect(true);//保存
//          }else{
//            mList.get(positon).setSelect(false);//保存
//          }
//        }
//      });
//     cb_exercise1.setChecked(  mList.get(positon).isSelect());
//
//      cb_exercise2.setOnClickListener(new View.OnClickListener() {
//        @Override
//        public void onClick(View v) {
//          if(cb_exercise2.isChecked())
//          {
//            mList.get(positon).setSelect(true);//保存
//          }else{
//            mList.get(positon).setSelect(false);//保存
//          }
//        }
//      });
//     cb_exercise2.setChecked( mList.get(positon).isSelect());
//
//      cb_exercise3.setOnClickListener(new View.OnClickListener() {
//        @Override
//        public void onClick(View v) {
//          if(cb_exercise3.isChecked())
//          {
//            mList.get(positon).setSelect(true);//保存
//          }else{
//            mList.get(positon).setSelect(false);//保存
//          }
//        }
//      });
//      cb_exercise3.setChecked(  mList.get(positon).isSelect());
//
//      cb_exercise4.setOnClickListener(new View.OnClickListener() {
//        @Override
//        public void onClick(View v) {
//          if(cb_exercise4.isChecked())
//          {
//            mList.get(positon).setSelect(true);//保存
//          }else{
//            mList.get(positon).setSelect(false);//保存
//          }
//        }
//      });
//      cb_exercise4.setChecked(  mList.get(positon).isSelect());
//
//      cb_exercise5.setOnClickListener(new View.OnClickListener() {
//        @Override
//        public void onClick(View v) {
//          if(cb_exercise5.isChecked())
//          {
//            mList.get(positon).setSelect(true);//保存
//          }else{
//            mList.get(positon).setSelect(false);//保存
//          }
//        }
//      });
//      cb_exercise5.setChecked( mList.get(positon).isSelect());

        }
    }


    public class PopWindowTypeApt extends CommonAdapter<ExerciseTypeBean> {
        private Context context;
        private List<ExerciseTypeBean> mList;

        public PopWindowTypeApt(Context context, List<ExerciseTypeBean> mList, int itemLayoutId) {
            super(context, mList, itemLayoutId);
            this.context = context;
            this.mList = mList;
        }

        @Override
        public void convert(ViewHolder holder, ExerciseTypeBean item, int positon) {
            TextView tv_company = (TextView) holder.getView(R.id.tv_company);
            String Name = mList.get(positon).getTypename();
            tv_company.setText(Name);
        }
    }

}
